package com.cclinux.projects.actcampus.mapper;

import com.cclinux.framework.core.mapper.ProjectBaseMapper;
import com.cclinux.projects.actcampus.model.ActivityClassModel;
import com.cclinux.projects.actcampus.model.ActivityJoinClassModel;
import com.cclinux.projects.actcampus.model.ActivityJoinModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository("ActCampusActivityClassMapper")
@Mapper
public interface ActivityClassMapper extends ProjectBaseMapper<ActivityClassModel> {



    // 根据用户报名活动id查询对应的课程列表
    @Select("SELECT a.ACTIVITY_JOIN_CLASS_ID, a.ACTIVITY_USE_STATUS, b.ACTIVITY_CLASS_TITLE activityClassTitle," +
            "  b.ACTIVITY_CLASS_CONTENT activityClassContent, a.LESSON_TIME lessonTime FROM actcampus_activity_join_class a " +
            " LEFT JOIN actcampus_activity_class b " +
            " on a.ACTIVITY_CLASS_ID = b.ACTIVITY_CLASS_ID " +
            " WHERE ACTIVITY_JOIN_ID = #{joinId} and ACTIVITY_JOIN_USER_ID = #{userId} ")
    List<ActivityJoinClassModel> selectByJoinIdAndClassId(long  joinId, long userId);


    @Select("SELECT a.ACTIVITY_JOIN_CLASS_ID, a.ACTIVITY_USE_STATUS, b.ACTIVITY_CLASS_TITLE activityClassTitle," +
            "  b.ACTIVITY_CLASS_CONTENT activityClassContent FROM actcampus_activity_join_class a " +
            " LEFT JOIN actcampus_activity_class b " +
            " on a.ACTIVITY_CLASS_ID = b.ACTIVITY_CLASS_ID " +
            " WHERE ACTIVITY_JOIN_ID = #{joinId} and ACTIVITY_JOIN_USER_ID = #{userId} ")
    List<ActivityJoinClassModel> selectByJoinIdAndClassIdNoUseStatus(long  joinId, long userId);

    @Select("SELECT b.ACTIVITY_TITLE activityTitle, c.USER_ACCOUNT userMobile FROM actcampus_activity_join a LEFT JOIN \n" +
            "actcampus_activity b on a.ACTIVITY_JOIN_ACTIVITY_ID = b.ACTIVITY_ID\n" +
            "\n" +
            "LEFT JOIN \n" +
            "actcampus_user c on a.ACTIVITY_JOIN_USER_ID = c.USER_ID \n" +
            "WHERE a.ACTIVITY_JOIN_ID = #{joinId}  and a.ACTIVITY_JOIN_USER_ID = #{userId}")
    ActivityJoinClassModel selectByJoinIdAndUserId(long  joinId, long userId);



}
